﻿<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html lang="zh_CN">
<head>
<%@ include file="../common/header.jsp"%>
<script type="text/javascript" src="/js/My97DatePicker/WdatePicker.js"></script>
</head>
<body>

	<div class="container " style="margin-top: 20px">
		<%@ include file="../common/top.jsp"%>

		<div class="row">
			<div class="col-sm-3">
				<c:set var="menu" value="customerTraceHistory" />
				<%@ include file="../common/menu.jsp"%>
			</div>
			<div class="col-sm-9">
				<div class="row">
					<div class="col-sm-12">
						<h1 class="page-head-line">跟进历史管理</h1>
					</div>
				</div>
				<form class="form-inline" id="searchForm" action="/customerTraceHistory/list.do"
					method="post">
					<input type="hidden" name="currentPage" id="currentPage" value="1">
					<div class="form-group">
						<label>关键字:</label> <input type="text" class="form-control"
							name="keyword" value="${qo.keyword}" placeholder="请输入客户姓名/录入人">
					</div>
					<div class="form-group">
	                    <label>时间:</label>
	                    <input type="text" class="form-control" name="beginDate"
	                           value='<fmt:formatDate value="${qo.beginDate}" pattern="yyyy-MM-dd"/>' placeholder="请输入开始时间"/>
	                    <input type="text" class="form-control" name="endDate"
	                           value="<fmt:formatDate value="${qo.endDate}" pattern="yyyy-MM-dd"/>" placeholder="请输入结束时间"/>
	                </div>

					<button type="submit" class="btn btn-primary">
						<span class="glyphicon glyphicon-search"></span> 查询
					</button>
				</form>

				<table class="table table-striped table-hover">
					<tr>
						<th>编号</th>
						<th>客户姓名</th>
						<th>跟进时间</th>
						<th>跟进内容</th>
						<th>跟进方式</th>
						<th>跟进结果</th>
						<th>录入人</th>
						<th>操作</th>
					</tr>

					<c:forEach var="entity" items="${pageInfo.list}">
						<tr>
							<td>${entity.id}</td>
							<td>${entity.customer.name}</td>
							<td><fmt:formatDate value="${entity.traceTime}" pattern="yyyy-MM-dd HH:mm"/></td>
							<td>${entity.traceDetails}</td>
							<td>${entity.traceTypeName}</td>
							<td>${entity.traceResultName}</td>
							<td>admin</td>
							<td>
								<a class="btn btn-info btn-xs inputBtn" data-json='${entity.json}'> 
									<span class="glyphicon glyphicon-pencil"></span> 编辑
								</a>
							</td>
						</tr>
					</c:forEach>

				</table>

				<%@ include file="../common/page.jsp"%>
			</div>
		</div>
	</div>
	<!-- 跟进历史 -->
	<div class="modal fade" id="traceModal" tabindex="-1" role="dialog" aria-hidden="true">
	    <div class="modal-dialog">
	        <div class="modal-content">
	            <div class="modal-header">
	                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
	                <h4 class="modal-title">跟进历史</h4>
	            </div>
	            <div class="modal-body">
	                <!--填充编辑界面-->
	                <form class="form-horizontal" action="/customerTraceHistory/saveOrUpdate.do" method="post" id="editForm">
	                    <input type="hidden" name="id"/>
	                    <input type="hidden" name="customer.id"/>
	                    <div class="form-group" >
	                        <label class="col-lg-4 control-label">客户姓名：</label>
	                        <div class="col-lg-6">
	                            <input type="text" class="form-control" id="customerName" readonly/>
	                        </div>
	                    </div>
	                    <div class="form-group">
	                        <label class="col-lg-4 control-label">跟进时间：</label>
	                        <div class="col-lg-6">
	                            <input type="text" class="form-control" name="traceTime"  onclick="WdatePicker({maxDate:new Date()});"
	                             placeholder="请输入跟进时间" readonly/>
	                        </div>
	                    </div>
	                    <div class="form-group">
	                        <label class="col-lg-4 control-label">跟进记录：</label>
	                        <div class="col-lg-6">
	                            <input type="text" class="form-control" name="traceDetails"
	                                   placeholder="请输入跟进记录"/>
	                        </div>
	                    </div>
	                    <div class="form-group">
	                        <label class="col-lg-4 control-label">交流方式：</label>
	                        <div class="col-lg-6">
	                            <select class="form-control" name="traceTypeId">
	                            	<c:forEach var="t" items="${types}">
	                                    <option value="${t.id}">${t.title}</option>
	                            	</c:forEach>
	                            </select>
	                        </div>
	                    </div>
	                    <div class="form-group">
	                        <label class="col-lg-4 control-label">跟进结果：</label>
	                        <div class="col-lg-6">
	                            <select class="form-control" name="traceResult">
	                                <option value="3">优</option>
	                                <option value="2">中</option>
	                                <option value="1">差</option>
	                            </select>
	                        </div>
	                    </div>
	                    <div class="form-group">
	                        <label class="col-lg-4 control-label">备注：</label>
	                        <div class="col-lg-6">
	                            <textarea type="text" class="form-control" name="remark"></textarea>
	                        </div>
	                    </div>
	                </form>
	            </div>
	            <div class="modal-footer">
	                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
	                <button type="button" class="btn btn-primary traceSubmitBtn">保存</button>
	            </div>
	        </div>
	    </div>
	</div>
		

<script>
	$(function() {
		
		$(".inputBtn").click(function() {
			var json = $(this).data("json");
			console.log(json);
			if (json) {
				$("#editForm input[name='id']").val(json.id);
				$("#editForm input[name='customer.id']").val(json.customerId);
				$("#editForm input[id='customerName']").val(json.customerName);
				$("#editForm input[name='traceTime']").val(json.traceTime);
				$("#editForm input[name='traceDetails']").val(json.traceDetails);
				$("#editForm select[name='traceTypeId']").val(json.traceTypeId);
				$("#editForm select[name='traceResult']").val(json.traceResult);
				$("#editForm textarea[name='remark']").val(json.remark);
			}
			$("#traceModal").modal("show");
			
		});		

		
		$(".traceSubmitBtn").click(function() {
			$("#editForm").submit();
		});
		
		
		////////////////////
		$("#searchForm input[name='beginDate']").click(function () {
            WdatePicker({
                readOnly: true, //只读
                maxDate: new Date() //最多选到今天
            });
        });
		
		$("#searchForm input[name='endDate']").click(function() {
			WdatePicker({
				readOnly: true,
				minDate: $("#searchForm input[name='beginDate']").val(),
				maxDate: new Date()
			});
		});
		
		
	})
</script>
</body>
</html>